<template>
  <el-dialog
    title="注销"
    :visible.sync="visible"
    width="1150px"
    :show-close="false"
    :before-close="close"
  >
    <div class="content">
      <div class="box-title">
        <div class="title">基本信息</div>
      </div>
      <div class="box-content box-content1">
        <div class="picture-box">
          <div class="default-picture">
            <span>证件照片</span>
          </div>
          <img class="picture" v-if="info.zp" :src="'data:image/jpg;base64,' + info.zp" alt="" />
        </div>
        <ul class="info-list info-list1">
          <li class="info-item">
            <div class="title">身份证号：</div>
            <div class="value">{{info.sfzh || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">姓名：</div>
            <div class="value">{{info.xm || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">性别：</div>
            <div class="value">{{info.xb || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">民族：</div>
            <div class="value">{{info.mz || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">出生日期：</div>
            <div class="value">{{info.csrq || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">曾用名：</div>
            <div class="value">{{info.cym || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">手机号码：</div>
            <div class="value">{{info.lxdh || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">户籍地址：</div>
            <div class="value long-value">{{info.hddd || '无'}}</div>
          </li>
        </ul>
      </div>

      <div class="box-title">
        <div class="title">居住信息</div>
      </div>
      <div class="box-content">
        <ul class="info-list info-list2">
          <li class="info-item">
            <div class="title">暂(居)住地址：</div>
            <div class="value long-value">{{info.zzdz || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">迁(流)入日期：</div>
            <div class="value">{{info.qrrq || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">暂(居)住处所：</div>
            <div class="value">{{info.zzcs || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">申请期限：</div>
            <div class="value">{{info.sqqx || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">暂(居)住事由：</div>
            <div class="value">{{info.zzsy || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">来自地国家：</div>
            <div class="value">{{info.lzdgj || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">来自地住址：</div>
            <div class="value long-value">{{info.lzdzz || '无'}}</div>
          </li>
        </ul>
      </div>

      <div class="box-title">
        <div class="title">联系人信息</div>
      </div>
      <div class="box-content">
        <ul class="info-list info-list3">
          <li class="info-item">
            <div class="title">身份证号：</div>
            <div class="value">{{info.lxrsfzh || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">姓名：</div>
            <div class="value">{{info.lxrxm || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">社会关系：</div>
            <div class="value">{{info.lxrshgx || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">手机号码：</div>
            <div class="value">{{info.lxrdh || '无'}}</div>
          </li>
          <li class="info-item">
            <div class="title">住址信息：</div>
            <div class="value long-value">{{info.lxrzzxx || '无'}}</div>
          </li>
        </ul>
      </div>

    </div>
    <div class="buttons">
      <el-button class="dialog-btn" @click="submit">注销</el-button>
      <el-button class="dialog-btn outline" @click="close">取消</el-button>
    </div>
  </el-dialog>
</template>

<script type="text/ecmascript-6">
import { getStore } from '@/utils/storage'
import { getDicVal } from '@/utils/utils'

export default {
  name: 'record-info',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    cardNum: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      info: {
        id: '',
        zp: '',
        sfzh: '',
        xm: '',
        xb: '',
        mz: '',
        csrq: '',
        cym: '',
        lxdh: '',
        hddd: '',

        zzdz: '',
        qrrq: '',
        zzcs: '',
        sqqx: '',
        zzsy: '',
        lzdgj: '',
        lzdzz: '',

        lxrsfzh: '',
        lxrxm: '',
        lxrshgx: '',
        lxrdh: '',
        lxrzzxx: ''
      },
      sexData: [],
      mzData: [],
      ztData: []
    }
  },
  created () {
    this.sexData = JSON.parse(getStore('dictionary')).XB
    this.mzData = JSON.parse(getStore('dictionary')).MZ
    this.ztData = JSON.parse(getStore('dictionary')).ZZBS
    if (this.cardNum) {
      this.getPersonInfo(this.cardNum)
    }
  },
  methods: {
    close () {
      this.$emit('close', false)
    },
    submit () {
      this.$emit('submit', this.info.id)
    },
    // 获取人员信息
    async getPersonInfo (val) {
      let res = await this.$http(this.$api.getPersonInfoFy, { gmsfhm: val })
      if (res.code === 200) {
        if (!res.data) {
          console.error('登记卡信息查询失败')
          return
        }
        let d = res.data
        this.info = {
          id: d.id,
          zp: d.dyzpUrl ? d.dyzpUrl : '', // 照片
          sfzh: d.gmsfhm, // 身份证号码
          xm: d.xm,
          xb: getDicVal(this.sexData, d.xbdm.trim()),
          mz: getDicVal(this.mzData, d.mzdm.trim()),
          csrq: this.formatBirth(d.csrq),
          cym: d.cym,
          lxdh: d.lxdh,
          hddd: d.hjdzSsxqmc + d.hjdzQhnxxdz,

          zzdz: d.zjzdzSsxqmc + d.zjzdzQhnxxdz,
          qrrq: this.formatBirth(d.qlrrq),
          zzcs: d.zjzcsfldm,
          sqqx: d.sqqx,
          zzsy: d.zjzsydm,
          lzdgj: d.lzdGjhdqdm,
          lzdzz: d.lzdSsxqmc + d.lzdQhnxxdz,

          lxrsfzh: d.lxrGmsfhm,
          lxrxm: d.lxrXm,
          lxrshgx: d.lxrRygxdm,
          lxrdh: d.lxrLxdh,
          lxrzzxx: d.lxrSsxqmc + d.lxrQhnxxdz
        }
      }
    },
    formatBirth (val) {
      return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8)
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .el-dialog__header {
  padding: 16px 26px;
  font-size: 18px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #333333;
  border-bottom: 1px solid #eeeeee;
}
/deep/ .el-dialog__body {
  padding: 10px 20px;
}
.content {
  height: 500px;
  overflow-y: auto;
  .box-title {
    border-bottom: 1px solid #02579a;
    .title {
      padding: 0 6px;
      height: 30px;
      line-height: 30px;
      display: inline-block;
      background-color: #02579a;
      color: #fff;
      border-radius: 6px 6px 0 0;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
    }
  }
  .box-content {
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
    background-color: #edf4fa;
    &.box-content1 {
      display: flex;
    }

    .picture-box {
      margin-right: 20px;
      width: 100px;
      height: 120px;
      position: relative;
      overflow: hidden;
      border: 1px solid #c9c9c9;

      .default-picture {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: url("../../../assets/images/default-pic.png") no-repeat 50%
          17px;
        background-size: 61px 58px;

        span {
          display: inline-block;
          width: 100%;
          position: absolute;
          top: 93px;
          left: 0;
          text-align: center;
          font-size: 14px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #d8dee3;
          line-height: 16px;
        }
      }

      .picture {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
    }
    .info-list {
      flex: 1;
      display: flex;
      flex-wrap: wrap;
      .info-item {
        height: 30px;
        padding-top: 8px;
        line-height: 1.5;
        display: flex;
        .title {
          text-align: right;
        }
      }
      &.info-list1 {
        .info-item {
          .title {
            width: 75px;
          }
          .value {
            width: 240px;
            &.long-value {
              width: 558px;
            }
          }
        }
      }
      &.info-list2 {
        .info-item {
          .title {
            width: 110px;
          }
          .value {
            width: 245px;
            &.long-value {
              width: 960px;
            }
          }
        }
      }
      &.info-list3 {
        .info-item {
          .title {
            width: 110px;
          }
          .value {
            width: 245px;
            &.long-value {
              width: 600px;
            }
          }
        }
      }
    }
    &.box-content2 {
      background-color: transparent;
      padding: 0;
      .table-list {
        width: 100%;
        .table-tr {
          display: flex;
          .table-td {
            height: 50px;
            line-height: 50px;
            width: 16.666%;
            text-align: center;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            word-break: none;
          }
        }
        &.table-header {
          .table-tr {
            .table-td {
              background-color: #e8edf1;
            }
          }
        }
      }
    }
  }
}
.buttons {
  padding-top: 20px;
  text-align: center;
  .dialog-btn {
    padding: 0;
    width: 140px;
    height: 40px;
    line-height: 38px;
    border-radius: 0;
    border: 1px solid #02579a;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #ffffff;
    background: #02579a;
    margin-left: 20px;
    &.outline {
      color: #02579a;
      background: #fff;
    }
  }
}
</style>
